#include "testrle.h"
//-----------------------------------------------------------------------------
#include <QVector>
#include "rlecompressor.h"
//-----------------------------------------------------------------------------
TestRle::TestRle(QObject *parent) :
    QObject(parent)
{
}
//-----------------------------------------------------------------------------
void TestRle::initTestCase()
{
    this->mTestVector1 = new QVector<quint32>();
    this->mTestVector2 = new QVector<quint32>();

    (*this->mTestVector1)
            << 1
            << 2 << 2 << 2
            << 3 << 3
            << 4
            << 5 << 5 << 5 << 5 << 5
            << 6
            << 7
            << 8 << 8 << 8 << 8
            << 9
            << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10
            << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10
            << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10
            << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10
            << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10
            << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10
            << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10
            << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10
            << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10
            << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10
            << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10
            << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10
            << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10
               ;

    (*this->mTestVector2)
            << ((quint32)-1) << 1
            << 3 << 2
            << 2 << 3
            << ((quint32)-1) << 4
            << ((quint32)5) << 5
            << ((quint32)-2) << 6 << 7
            << 4 << 8
            << ((quint32)-1)<< 9
            << 127 << 10
            << 3 << 10;
}
//-----------------------------------------------------------------------------
void TestRle::compress()
{
    RleCompressor compressor;

    QVector<quint32> test;
    compressor.compress(this->mTestVector1, Data8, &test);

    QCOMPARE(test.size(), this->mTestVector2->size());
    for (int i = 0; i < test.size(); i++)
    {
        QCOMPARE(test.at(i), this->mTestVector2->at(i));
    }
}
//-----------------------------------------------------------------------------
void TestRle::cleanupTestCase()
{
    delete this->mTestVector1;
    delete this->mTestVector2;
}
//-----------------------------------------------------------------------------
